﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<CRM.Database.Model.TrucksCapacities>>" %>
<%@ Import Namespace="CRM.Database.Model" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdTrucksCapacities";
                                        settings.KeyFieldName = "IdTrucksCapacity";
                                        settings.CallbackRouteValues =
                                            new { Controller = "Dictionaries", Action = "TrucksCapacitiesPartial" };
                                        settings.SettingsPager.PageSize = 20;
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.Capacity;
                                            column.FieldName = "Capacity";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.CapacityForCalculation;
                                            column.FieldName = "CapacityForCalculation";
                                        });

                                        //Добавление локализованного комбобокса
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "IdUnit";
                                            column.Caption = Resourses.Units;
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                var col = new UnitsCollection();
                                                comboBoxProperties.DataSource =col.UnitsList;
                                                comboBoxProperties.TextField = "LocalizedName";
                                                comboBoxProperties.ValueField = "IdUnit";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });
                                        //конец комбобокса

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.IsActive;
                                            column.FieldName = "IsActive";
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });

                                        //Добавление редактирования
                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Dictionaries", Action = "TrucksCapacitiesPartialUpdate" };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Dictionaries", Action = "TrucksCapacitiesPartialAdd" };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Dictionaries", Action = "TrucksCapacitiesPartialDelete" };
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);
                                    }).Bind(Model).GetHtml();%>


